package com.sitechasia.webx.components.xtable.customertag;


import org.extremecomponents.table.bean.Row;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.table.tag.RowTag;
import org.extremecomponents.table.tag.TagUtils;

/**
*
* <p>版权所有：中企动力
* <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
* <p>功能描述：自定义row标签类，加入id和ondblclick属性
*
* @author kuanglingxuan
* Created on 2007-8-15
*/
public class CeRowTag extends RowTag {

	private String id;
	private String ondblclick;
	private String onContextMenu;

	/**
	 * 功能描述：Row对象创建的时候被调用
	 */
	public void addRowAttributes(TableModel model, Row row){
		row.addAttribute("id", TagUtils.evaluateExpressionAsString("id", id, this, pageContext));
		row.addAttribute("ondblclick", TagUtils.evaluateExpressionAsString("ondblclick", ondblclick, this, pageContext));
		row.addAttribute("onContextMenu", TagUtils.evaluateExpressionAsString("onContextMenu", getOnContextMenu()==null?null:row.getOnclick()==null?getOnContextMenu():"this.onclick();"+getOnContextMenu(), this, pageContext));
    }

	/**
	 * 功能描述：列表生成每一行数据的时候调用一次
	 */
	public void modifyRowAttributes(TableModel model, Row row){
		row.addAttribute("id", TagUtils.evaluateExpressionAsString("id", id, this, pageContext));
		row.addAttribute("ondblclick", TagUtils.evaluateExpressionAsString("ondblclick", ondblclick, this, pageContext));
		modefyRowStyle(model,row);
	}

	/**
	 *
	     * Function:修改表格行的样式属性.如果stsyleClass为空,则默认为"grid"
	     * Create author:yixianjian
	     * Create on:2008-5-15
	 */
	private void modefyRowStyle(TableModel model, Row row){
		String styleClass = row.getStyleClass();
		String defaultStyleClass = styleClass != null?styleClass:"grid";
		row.setStyleClass(defaultStyleClass);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getOndblclick() {
		return ondblclick;
	}

	public void setOndblclick(String ondblclick) {
		this.ondblclick = ondblclick;
	}
	public String getOnContextMenu() {
		return onContextMenu;
	}

	public void setOnContextMenu(String onContextMenu) {
		this.onContextMenu = onContextMenu;
	}
}
